package com.htgd.gardenexpo.service.impl;

import com.htgd.gardenexpo.entity.GeBaseUser;
import com.htgd.gardenexpo.dao.GeBaseUserDao;
import com.htgd.gardenexpo.service.GeBaseUserService;
import com.htgd.gardenexpo.vo.Person;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 系统用户表(GeBaseUser)表服务实现类
 *
 * @author makejava
 * @since 2021-05-31 13:51:01
 */
@Service("geBaseUserService")
public class GeBaseUserServiceImpl implements GeBaseUserService {
    @Resource
    private GeBaseUserDao geBaseUserDao;

    /**
     * 通过ID查询单条数据
     *
     * @param userId 主键
     * @return 实例对象
     */
    @Override
    public GeBaseUser queryById(Integer userId) {
        return this.geBaseUserDao.queryById(userId);
    }

    @Override
    public GeBaseUser getuserinfobypopenid(String openId) {
        return this.geBaseUserDao.getUserInfoByPopenId(openId);
    }

    @Override
    public GeBaseUser getuserinfobyWxopenid(String openId) {
        return this.geBaseUserDao.getuserinfobyWxopenid(openId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GeBaseUser> queryAllByLimit(int offset, int limit) {
        return this.geBaseUserDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param geBaseUser 实例对象
     * @return 实例对象
     */
    @Override
    public GeBaseUser insert(GeBaseUser geBaseUser) {
        this.geBaseUserDao.insert(geBaseUser);
        return geBaseUser;
    }

    @Override
    public List<GeBaseUser> getUserByPhone(String phone) {
        return this.geBaseUserDao.getUserByPhone(phone);
    }

    @Override
    public List<GeBaseUser> getAllUserByValueAndIds(String value,String[] id) {
        return this.geBaseUserDao.getAllUserByValueAndIds(value,id);
    }

    @Override
    public List<GeBaseUser> getAllUserByValue(String value,Integer type,Integer status,String starttime,String endtime,String birstime,String biretime,String[] id,int pageNum,int pageSize) {
        return this.geBaseUserDao.getAllUserByValue(value,type,status,starttime,endtime,birstime,biretime,id,pageNum,pageSize);
    }

    /**
     * 修改数据
     *
     * @param geBaseUser 实例对象
     * @return 实例对象
     */
    @Override
    public GeBaseUser update(GeBaseUser geBaseUser) {
        this.geBaseUserDao.update(geBaseUser);
        return this.queryById(geBaseUser.getUserId());
    }

    /**
     * 通过主键删除数据
     *
     * @param userId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer userId) {
        return this.geBaseUserDao.deleteById(userId) > 0;
    }

    @Override
    public List<Person> getAllUser() {
        return geBaseUserDao.getAllUser();
    }

    @Override
    public List<GeBaseUser> list() {
        return geBaseUserDao.list();
    }

    @Override
    public void updateDeleFlag(String phone) {
        geBaseUserDao.updateDeleFlag(phone);
    }

    @Override
    public void updateByPhone(GeBaseUser geBaseUser) {
        geBaseUserDao.updateByPhone(geBaseUser);
    }

    @Override
    public GeBaseUser getUserById(int userId) {
        return geBaseUserDao.getUserById(userId);
    }
}
